<template>
  <div>
    <van-tabbar
      v-model="actives"
      active-color="#F63515"
      inactive-color="#000"
      fixed
    >
      <van-tabbar-item @click="home" icon="wap-home-o">首页</van-tabbar-item>
      <van-tabbar-item @click="home" icon="point-gift-o"
        >分类</van-tabbar-item
      >
      <van-tabbar-item @click="home" icon="shopping-cart-o" v-if="$store.getters.getBadgeCount>0" :badge="$store.getters.getBadgeCount"
        >购物车</van-tabbar-item
      >
       <van-tabbar-item @click="home" icon="shopping-cart-o" v-else 
        >购物车</van-tabbar-item
      >
      <van-tabbar-item @click="home" icon="user-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>

export default {
  data() {
    return {
      actives: this.active,
    };
  },
  props: {'active':{type:Number,default:0}},
  methods: {
    home() {
      if (this.actives == 0) {
        this.$router.push("/").catch(() => {});
      } else if (this.actives == 1) {
        this.$router.push("/category").catch(() => {});
      } else if (this.actives == 2) {
        this.$router.push("/shopcart").catch(() => {});
      } else {
        this.$router.push("/user").catch(() => {});
      }
    },
  },
};
</script>

<style scoped>
</style>